package game.dungeon;
import game.dungeon.position.Coordinate;
import game.dungeon.position.CoordinateType;
import game.dungeon.position.Position;
import game.square.SquareImpl;
import be.kuleuven.cs.som.annotate.Basic;
import be.kuleuven.cs.som.annotate.Immutable;

/**
 * A class of levels used as a special type of singular dungeon.
 *  
 * @version 1.0
 * @author Chris Desomer, Geert Heyman
 */

public class Level<S extends SquareImpl> extends SingularDungeon<S> {

	/**
	 * Initialize a new level, with the given boundary position and fixed z-coordinate.
	 * 
	 * @param 	boundaryPosition
	 * 			The boundary position for this new level.
	 * @param 	height
	 * 			The height for this new level.
	 * @pre		The given boundary position must be effective.
	 * 		  | boundaryPosition != null
	 * @pre		..
	 * 		  | height != null
	 * @pre		..
	 * 		  | height.getCoordinateType() == CoordinateType.ZCOORDINATE
	 * @effect	..
	 * 		  | super(boundaryPosition)
	 * @post	..
	 * 		  | new.getHeight() == height
	 * 
	 */ 
	public Level(Position boundaryPosition, Coordinate height) {
		super(boundaryPosition);
		assert (height != null);
		assert(height.getCoordinateType() == CoordinateType.ZCOORDINATE);
		this.height = height;
	}
	
	/**
	 * Get the height of this level.
	 */
	@Basic
	@Immutable
	public Coordinate getHeight(){
		return height;
	}
	
	/**
	 * Variable that references the height of this level.
	 */
	private final Coordinate height;

	/**
	 * Check if this level can have the given position as one of its positions.
	 * 
	 * @param	position
	 * 			The position to check.
	 * @return	..
	 * 		  | if (!super.canHaveAsPosition(position))
	 * 		  |		then result == false
	 * @result	..
	 * 		  |	else if (!(position.getCoordinate(getHeight.getCoordinateType()) == 
	 * 		  |		getHeight.getCoordinateValue()))
	 * 		  |		then result == false
	 * @result	..
	 * 		  |	else then result == true
	 */
	@Override
	public boolean canHaveAsPosition(Position position) {
		if (!super.canHaveAsPosition(position))
			return false;
		if (!(position.getCoordinate(getHeight().getCoordinateType()) == 
			getHeight().getCoordinateValue()))
			return false;
		return true;
	}

}
